import 'package:fish_redux/fish_redux.dart';
import 'package:hayll_app_village_master/hayll/village_manager/home/grid/village_house_picker_component/component.dart';
import 'package:hayll_app_village_master/hayll/village_manager/home/grid/village_house_picker_component/state.dart';

import 'effect.dart';
import 'reducer.dart';
import 'state.dart';
import 'view.dart';

class VillageHouseChoosePage
    extends Page<VillageHouseChooseState, Map<String, dynamic>> {
  VillageHouseChoosePage()
      : super(
          initState: initState,
          effect: buildEffect(),
          reducer: buildReducer(),
          view: buildView,
          dependencies: Dependencies<VillageHouseChooseState>(
              adapter: null,
              slots: <String, Dependent<VillageHouseChooseState>>{
                'housePicker':
                    ChooseHouseConnector() + VillageHousePickerComponent(),
              }),
          middleware: <Middleware<VillageHouseChooseState>>[],
        );
}

class ChooseHouseConnector
    extends ConnOp<VillageHouseChooseState, VillageHousePickerState> {
  @override
  VillageHousePickerState get(VillageHouseChooseState state) {
    return state.pickerState;
  }

  @override
  void set(VillageHouseChooseState state, VillageHousePickerState subState) {
    state.pickerState = subState;
  }
}
